
<template>
  <MyLayout>

    <Card style="margin:30px;">
      <p slot="title" class="topic-filter" activeName="">
        <span @click="topic(1)" :class="topicActive(1)">最新</span>
        <span @click="topic(2)" :class="topicActive(2)">最赞</span>
        <span @click="topic(3)" :class="topicActive(3)">最热门</span>
      </p>
      <div>
        频道：{{rt.channel}}<br>
        排序：{{rt.order}}<br>
        页码：{{rt.page}}<br>
        <hr>
      <ul class="list-group row topic-list">
        <li class="list-group-item " style="padding: 10px;border-bottom: 1px solid #dddddd;" v-for="i of 6">
          html和css的一些常用标签使用
        </li>

      </ul>

        <Page :total="100" :current="rt.page" @on-change="onPageChange" />
      </div>
    </Card>

  </MyLayout>
</template>
<script>
  import {star,getDemoName} from "@/utils/service"
  import MyLayout from '@/components/MyLayout'
  export default {
    components: {MyLayout},
    data () {
      return {
        //page:Number.parseInt(this.$route.query.page||1),
        //order:this.$route.query.order||1,
        rt:{
          channel:this.$route.params.id,
          page:Number.parseInt(this.$route.query.page||1),
          order:(this.$route.query.order||1)
        }
      }
    },
    methods: {
      topic:function (order) {
        this.rt.order=order;
        this.to();
      },
      onPageChange:function (page) {
        this.rt.page=page;
        this.to();
      },
      to:function () {
        var that = this;
        this.$router.push({
          path : that.$route.path ,
          query:{
            order:that.rt.order,
            page:that.rt.page
          }
        })
      }
    },
    computed:{
      topicActive(){
        return (v)=>{
          return (this.rt.order==v)? "active":"";
        }
      }
    },
    created () {

    },
    watch: {
      '$route' (to, from) {
          this.rt.channel=to.params.id;
          this.rt.order=to.query.order||1;
          this.rt.page=Number.parseInt(to.query.page||1);
          console.log("AJAX:"+JSON.stringify(this.rt))
          this.$Notice.success({
            title: 'AJAX接口',
            desc: JSON.stringify(this.rt)
          });
      }
    }
  }
</script>
<style scoped>

  .topic-filter span {
    color: #8b8a8a;
    text-decoration: none;
    font-size: 15px;
    padding: 1px 4px;
    line-height: 18px;
    cursor: pointer;
  }
  .topic-filter span.active{
    color: #03a9f4;
  }

  .list-group .list-group-item:first-child {
    border-top-left-radius: 0px;
    border-top-right-radius: 0px;
  }
  .list-group .list-group-item {
    padding: 0px 15px;
    border: none;
    margin-bottom: 0px;
    border-bottom: 1px solid #f2f2f2;
  }
  .topic-list .list-group-item {
    height: 58px;
  }
  .topic-list .reply_count_area {
    line-height: inherit;
  }
  .topic-list a, .topic-list a:focus, .topic-list a:hover {
    color: #555;
  }
  .reply_count_area {
    width: 200px;
    display: inline-block;
    text-align: right;
    float: left;
    line-height: 2em;
    margin-top: 18px;
  }
  .topic-list .list-group-item .avatar {
    margin-top: 2px;
  }
  .wrap .avatar {
    padding: 3px;
  }
  .avatar {
    border-radius: 50%;
  }
  .topic-list a, .topic-list a:focus, .topic-list a:hover {
    color: #555;
  }
  a {
    color: #333;
    text-decoration: none;
  }
  .topic-list .list-group-item .avatar.avatar-middle {
    width: 44px;
    height: 44px;
    padding: 0;
    border-color: #eee;
  }
  .topic-list .list-group-item .avatar {
    margin-top: 2px;
  }
  .streams .topic-list .media-heading {
    font-size: 15px;
    padding-top: 18px;
    padding-left: 8px;
  }

  .topic-list .media-heading {
    white-space: nowrap;
    overflow: hidden;
  }
  .topic-list .label {
    position: inherit;
    font-size: 12px;
    font-weight: normal;
    padding: 2px 6px;
  }
  .label-default {
    background-color: #f6f6f6;
    color: #999;
  }
  .topic-list a, .topic-list a:focus, .topic-list a:hover {
    color: #555;
  }
</style>
